﻿using System.Web.Http.Filters;

namespace Sustainalytics.Utils.WebApi.Filters
{
    public class CacheabilityActionFilterAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            if (actionExecutedContext.Response != null)
            {
                // HTTP 1.1.
                actionExecutedContext.Response.Headers.Add("Cache-Control", "no-cache, no-store, must-revalidate");

                // HTTP 1.0.
                actionExecutedContext.Response.Headers.Add("Pragma", "no-cache");
            }
        }
    }
}
